package com.doform.android.xianggucheng.activity.downorder;

import android.webkit.WebView;

import com.doform.android.xianggucheng.R;
import com.doform.android.xianggucheng.activity.BaseTitleActivity;
import com.doform.android.xianggucheng.help.AppHelp;
import com.doform.android.xianggucheng.utils.Constans;
import com.doform.android.xianggucheng.utils.TimeUtils;

/**
 * 作者 Y_MS
 * Created by ${APEN} on 2017-08-16.
 * GitHub：https://github.com/cxydxpx
 */

public class PayActivity extends BaseTitleActivity {

    private String mId;
    private WebView mWebView;

    @Override
    protected int layoutResId() {
        return R.layout.activity_pay;
    }

    @Override
    protected void init() {
        super.init();
        String id = getIntent().getStringExtra(Constans.EXTRA_PAY_CODE);
        this.mId = id;
    }

    @Override
    protected void initView() {
        super.initView();

        mWebView = (WebView) findViewById(R.id.webView);

        //设置WebView属性，能够执行Javascript脚本
        mWebView.getSettings().setJavaScriptEnabled(true);
        //加载需要显示的网页
        String url = "" +
                "http://api.maiwangtong.com/?" +
                "reqhead={" +
                "\"Function\":\"admin.transaction.orderpay.query\",\"ReqMsgId\":\"2881551a-6193-2bd3-a597-887b466d6826\"," +
                "\"ReqTime\":\""+ TimeUtils.getNowDateWithRequest() + "\",\"Version\":\"2.0\",\"" +
                "thusertoken\":\"" + AppHelp.getInstance().getToken() + "\"}" +
                "&reqbody={\"_savetype\":\"add\"," +
                "\"orderid\":\"" + mId + "\"}";
        mWebView.loadUrl(url);
//
//        mWebView.loadUrl("http://www.baidu.com");

    }

    @Override
    protected void showView() {
        titleBar.setTextTitle("支付");
    }
}
